<template>
	<el-card>
		<!-- 搜索 -->
		<el-form :model="searchData" inline ref="searchFormRef" v-resize="searchResize" label-width="90px">
			<el-form-item label="反馈内容" prop="content">
				<el-input v-model="searchData.content" placeholder="请输入反馈内容" clearable></el-input>
			</el-form-item>
			
			<el-form-item>
				<el-button icon="el-icon-search" type="primary" @click="searchClick">搜索</el-button>
				<el-button icon="el-icon-refresh" @click="resetClick">重置</el-button>
				<el-button icon="el-icon-plus" type="success" v-has="'sys:feedback:add'" @click="addShowClick">新增</el-button>
			</el-form-item>
		</el-form>
		<!-- 表格渲染 -->
		<YwTable ref="tableRef" :searchData="searchData" :tableProps="tableProps" api="sysfeedbackFindAllByPage">
			<!-- <el-table-column slot="table_oper" label="操作" fixed="right" width="170px">
				<template v-slot="scope">
					
					<el-button type="text" icon="el-icon-edit" @click="editShowClick(scope.row)"
						v-has="'sys:feedback:edit'">修改</el-button>
					<el-button type="text" icon="el-icon-delete" @click="deleteClick(scope.row)"
						v-has="'sys:feedback:delByIds'">删除</el-button>

					
				</template>
			</el-table-column> -->
		</YwTable>

		<!-- 添加/修改 -->
		<YwDialog @confirm="confirmClick" width="650px" ref="ywDialogRef" title="修改信息">
			<template slot="form">
				<el-form :model="curData" inline ref="curFormRef" label-width="95px" :show-message="false">

					<el-form-item label="幼儿园名称" prop="kgId" required>
						<el-select v-model="curData.kgId" placeholder="请选择幼儿园" style="width: 100%">
							<el-option v-for="(item, index) in kgList" :key="index" :value="item.id"
								:label="item.kgName" :disabled="item.status == 1"></el-option>
						</el-select>
					</el-form-item>
				
					<el-form-item label="班级名称" prop="feedbackName" required>
						<el-input v-model="curData.feedbackName" placeholder="请输入班级名称"></el-input>
					</el-form-item>

				</el-form>
			</template>
		</YwDialog>

	</el-card>
</template>

<script>
	export default {

		data() {
			return {
				//搜索条件
				searchData: {
					content: null,
				},
				//添加信息数据
				//修改信息数据
				//表单的值
				curData: {
					content: null,
					parentVxid:null,
					createTime: null,
				},
				//表格数据
				tableProps: [
					{
						label: "幼儿园名称",
						prop: "kgName"
					},
					{
						label: "班级名称",
						prop: "className"
					},
					{
						label: "学生名",
						prop: "studentName",
					},
					{
						label: "反馈人与学生关系",
						prop: "parentRelation"
					},
					{
						label: "反馈内容",
						prop: "content"
					},
					{
						label: "提交时间",
						prop: "createTime"
					},
				],
				
				
			};
		},
		
		mounted() {
			this.$nextTick(() => {
				this.$refs.tableRef.shuaxin(this.searchData);
				// this.getfkList();
			})

		},

		methods: {
			//搜索重置
			searchResize(data) {
				this.$refs.tableRef.refreshSize(data)
			},
			//获取反馈列表
			// getfkList() {
			// 	this.$api.sysfeedbackFindAllByList().then(data => {
			// 		this.FeedbackList = data;
			// 	});
			// },

			
			//添加/修改表单的确认按钮
			confirmClick() {
				let data = JSON.parse(JSON.stringify(this.curData))
				this.$refs.curFormRef.validate(async (valid) => {
					if (valid) {
						if (data.id) {
							//修改操作
							await this.$api.sysfeedbackEdit(data);
							
						} else {
							//添加操作
							await this.$api.sysfeedbackAdd(data)
						}
						this.$refs.ywDialogRef.close()
						this.searchClick()
					}
				});
			},
			//删除事件
			deleteClick(row) {
				this.$common.msgBoxDel(() => {
					this.$api.sysfeedbackDelByIds(row.id).then(res => {
						this.searchClick();
					});
				})
			},
			//新增按钮
			addShowClick() {
				this.curData = {
					feedbackName: null,
					kgName: null,
					createTime: null,
					
					
				
				}
				this.$refs.ywDialogRef.open()
			},
			//修改按钮
			editShowClick(row) {
				//给表单赋值

				this.$api.sysfeedbackFindById(row.id).then((result) => {
					this.curData = result;//实现表单赋值
				})	
				this.$refs.ywDialogRef.open()
			},

			//搜索按钮
			searchClick() {
				this.$refs.tableRef.shuaxin(this.searchData)
			},
			//重置按钮
			resetClick() {
				this.$refs.searchFormRef.resetFields();
				this.searchClick()
			},
		},
	};
</script>

<style lang="scss" scoped>
</style>
